<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
        <style>
            .box {
                background-color: #336699;
                height: 300px;
                width: 450px;
                margin-top: 10px;
            }

            /* 隐藏 => 显示 */
            .slide-enter {
                height: 0;
                opacity: 0;
            }

            .slide-enter-active {
                transition: all 0.5s ease;
            }

            .slide-enter-to {
                height: 300px;
                opacity: 1;
            }

            /* 显示 => 隐藏 */
            .slide-leave {
                height: 300px;
                opacity: 1;
            }

            .slide-leave-active {
                transition: height 0.5s ease;
            }

            .slide-leave-to {
                height: 0;
                opacity: 0;
            }
        </style>
    </head>
    <body>
        <div id="app">
            <button @click="flag = !flag">显示/隐藏</button>
            <transition name="slide">
                <div class="box" v-show="flag"></div>
            </transition>
            <div class="box"></div>
            <div class="box"></div>
        </div>
        <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
        <script>
            const vm = new Vue({
                el: '#app',
                data: {
                    flag: true,
                },
            });
        </script>
    </body>
</html>
